import {
  getCategoryGoodsCount,
  getCategoryGoodsSale,
  getCategoryGoodsFavor,
  getAddressGoodsSale,
} from "@/service/analysis/dashboread.js";

const dashboread = {
  namespaced: true,
  state: {
    categoryGoodsSale: [],
    categoryGoodsCount: [],
    categoryGoodsFavor: [],
    addressGoodsSale: [],
  },
  mutations: {
    changecategoryGoodsSale(state, list) {
      state.categoryGoodsSale = list;
    },
    changecategoryGoodsCount(state, list) {
      state.categoryGoodsCount = list;
    },
    changecategoryGoodsFavor(state, list) {
      state.categoryGoodsFavor = list;
    },
    changeaddressGoodsSale(state, list) {
      state.addressGoodsSale = list;
    },
  },
  actions: {
    async getdashboardData({ commit }, payload) {
      const categoryCountresult = await getCategoryGoodsCount();
      commit("changecategoryGoodsCount", categoryCountresult.data);
      const categorySalesresult = await getCategoryGoodsSale();
      commit("changecategoryGoodsSale", categorySalesresult.data);
      const categoryFavorresult = await getCategoryGoodsFavor();
      commit("changecategoryGoodsFavor", categoryFavorresult.data);
      const categoryAddressresult = await getAddressGoodsSale();
      commit("changeaddressGoodsSale", categoryAddressresult.data);
    },
  },
  getters: {},
};
export default dashboread;
